import axios from 'axios'
async function upload(path, userForm) {
  // 因为userForm中有文件，不能直接传给后端，要先做处理
  const params = new FormData()
  for (let i in userForm) {
    params.append(i, userForm[i])
  }
  // console.log(params)
  return axios.post(path, params, {
    headers: {
      // 告诉后端数据类型
      'Content-Type': 'multipart/form-data'
    }
  })
}

export default upload
